package org.raymond.iworks.apis.fallbackFactory;

import lombok.extern.slf4j.Slf4j;
import org.raymond.iworks.apis.ITRolePermissionServiceApi;
import org.raymond.iworks.apis.common.Result;
import org.raymond.iworks.apis.vo.role.UserRoleVO;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ITRolePermissionServiceFallbackFactory implements FallbackFactory<ITRolePermissionServiceApi> {
    @Override
    public ITRolePermissionServiceApi create(Throwable cause) {
        final String error = cause.getMessage();
        log.error(error, cause);
        return new ITRolePermissionServiceApi(){
            @Override
            public Result create(UserRoleVO vo) {
                return Result.error(error);
            }

            @Override
            public Result delete(UserRoleVO vo) {
                return Result.error(error);
            }
        };
    }
}
